<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>企业注册</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../css/main.css" media="all">
    <link rel="stylesheet" href="../../css/admin.css" media="all">
    <link rel="stylesheet" href="../../css/login.css" media="all">
</head>
<body>

<!-- 主体内容 -->
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>企业注册</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-nickname"></label>
                <input type="text" name="enterprisename" id="LAY-user-login-nickname" lay-verify="required"
                       placeholder="企业名称" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="pwd" placeholder="密码"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-repass"></label>
                <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="pwd" placeholder="确认密码"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone"
                       for="LAY-user-login-cellphone"></label>
                <input type="text" name="emailaccount" id="LAY-user-login-cellphone" lay-verify="email" placeholder="邮箱"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <div id="slider"></div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="enterprise-reg-submit">注 册</button>
            </div>
            <div class="layui-trans layui-form-item layadmin-user-login-other">
                <a href="enterpriseLogin.html" class="layadmin-user-jump-change layadmin-link layui-hide-xs">用已有帐号登入</a>
                <a href="enterpriseInfo.html" class="layadmin-user-jump-change layadmin-link layui-hide-xs">登入</a>
                <a href="enterpriseLogin.html"
                   class="layadmin-user-jump-change layadmin-link layui-hide-sm layui-show-xs-inline-block">用已有帐号登入</a>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p>© 2020 <a href="http://www.layui.com/" target="_blank">YNGS</a></p>
        <p>
            <span><a href="http://www.layui.com/admin/" target="_blank">云南工商学院</a></span>
        </p>
    </div>
</div>

<script src="../../libs/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['layer', 'form', 'jquery', 'sliderVerify', 'okUtils', 'okMd5'], function () {
        var sliderVerify = layui.sliderVerify
            , $ = layui.jquery
            , layer = layui.layer
            , form = layui.form
            , okUtils = layui.okUtils
            , okMd5 = layui.okMd5
            , slider = sliderVerify.render({
            elem: '#slider',
            onOk: function () {
                layer.msg("验证通过");
            }
        })


        form.render();

        form.verify({
            pwd: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"]
        });

        //提交
        form.on('submit(enterprise-reg-submit)', function (obj) {
            var field = obj.field;

            //确认密码
            if (field.password !== field.repass) {
                return layer.msg('两次密码输入不一致', {icon: 5});
            }

            if (slider.isOk()) {//用于表单验证是否已经滑动成功

            } else {
                return layer.msg("请先通过滑块验证");
            }
            var npwd = okMd5(field.password);
            field.password = npwd;
            okUtils.ajax("/ygssecs/registration", "post", obj.field, true).done(function (response) {
                layer.open({
                    type: 0,
                    title: "注册成功",
                    icon: 1,
                    area: "300px",
                    content: "注册成功,你的账号是 <p></p><b>" + response.data.enterpriseid + "</b></p> ,请妥善保管，这将是你的登录凭证",
                    end: function () {
                        location.href = "enterpriseLogin.html";
                    }
                });

            }).fail(function (error) {
                console.log(error)
            });
        });
    });
</script>
</body>
</html>